package com.system.oauthserver.service.imp;


import com.system.commonutils.pojo.UserBean;
import com.system.oauthserver.bean.SecurityUser;
import com.system.oauthserver.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

@Component
public class UserDetailsServiceImpl implements UserDetailsService {

    @Autowired
    UserService userService;

    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        UserBean userBean = userService.selectUserByUsername(s);
        SecurityUser securityUser = new SecurityUser(userBean);
        return securityUser;
    }

}
